package core.api;

import jade.util.Logger;

import java.util.ArrayList;
import java.util.List;

import core.datamodel.Constants;
import core.datamodel.Event;

public class FilterEvent {
	private List<String> acceptableResources;
	
	private Logger log = Logger.getJADELogger(this.getClass().getName());

	public FilterEvent(){
		acceptableResources=new ArrayList<String>();
		acceptableResources.add(Constants.RESOURCE_TYPE_VIRTUAL_MACHINE);
		acceptableResources.add(Constants.RESOURCE_TYPE_VLAN);
		acceptableResources.add(Constants.RESOURCE_TYPE_DATA_REPLICATION);

	}

	// discarde all not definited resource type
	public boolean discards( Event event){
		boolean out = true;
		if (event != null && event.getEventResource()!= null){
			for (String accept : acceptableResources ){
				if (accept.equals(event.getEventResource().getResourceType())){
					out = false;
					break;
				}
			}
			if (out)
				log.info("Attenzione Event con Resouce type: " + event.getEventResource().getResourceType()+ " viene scartato");
		}
		return out;
	}
}
